<template>
  <view class="container">
    <uni-nav-bar title="门店信息" fixed statusBar :border="false" height="88rpx" left-icon="left"
      @clickLeft="onClickLeft"></uni-nav-bar>
    <view class="inner">
      <view><text>门店名称：</text>{{ store.name }}</view>
      <view><text>赠送通证数量：</text>{{ store.tokenNum }}</view>
      <view><text>门店地址：</text>{{ store.region }}</view>
      <view><text>门店面积：</text>{{ store.area }}m&sup2;</view>
      <view><text>门店商圈：</text>{{ storeBus[store.businessDistrict] }}</view>
      <view><text>联系人：</text>{{ store.storeUser || '暂无' }}</view>
      <view><text>联系电话：</text>{{ store.storePhone || '暂无' }}</view>
      <view><text>分录日期：</text><uni-tag style="margin: 0 8rpx;color: #fff;white-space: nowrap" :text="it" type="primary"
          size="mini" v-for="(it, index) in enteryDate" :key="index" /></view>
    </view>
  </view>
</template>

<script>
import { getDictValueAndNameSource } from '@/apis/member.js'
import { reqStoreInfoByApp } from '@/apis/user.js'
export default {
  name: "StoreInfo",
  data() {
    return {
      store: {},
			storeBus:{},
    }
  },
  computed: {
    enteryDate() {
      if (!this.store.entriesDay) return [];
      const arr = this.store.entriesDay.split(',')
      const ent = arr.map(item => {
        if (item == 1) {
          return "周一"
        } else if (item == 2) {
          return "周二"
        } else if (item == 3) {
          return "周三"
        } else if (item == 4) {
          return "周四"
        } else if (item == 5) {
          return "周五"
        } else if (item == 6) {
          return "周六"
        } else if (item == 7) {
          return "周日"
        } else {
          return ""
        }
      })
      return ent
    }
  },
  onLoad() {
		this.getDictValueAndNameSource();
    this.getStoreInfo();
  },
  methods: {
    async getStoreInfo() {
      let res = await reqStoreInfoByApp();
      if (res.code === 200) {
        this.store = res.data;
        // this.store.entriesDay = '1,2,3,4,5,6,7'
      }
    },
		async getDictValueAndNameSource() {
			let res = await getDictValueAndNameSource("STORE_BUSINESS_AREA");
			if(res.code === 200) {
				this.storeBus = res.data;
			}
		}
  }
}
</script>
<style>
page {
  background: #f7f7f7;
}
</style>
<style lang="scss" scoped>
.inner {
  padding: 15rpx 24rpx;
  display: flex;
  flex-direction: column;
  align-items: center;

  view {
    width: 100%;
    word-break: break-all;
    margin-bottom: 35rpx;
    font-size: $uni-font-size-base;
    line-height: 1em;

    text {
      color: #747474;
    }
  }
}
</style>